package com.example.dragandview;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.example.dragandview.LockPatternView.LockNinePointActivity;
import com.example.dragandview.VerticalSlidle.VerticalSlideActivity;
import com.example.dragandview.animation.AnimationActivity;
import com.example.dragandview.diyview.ABCindexViewActivity;
import com.example.dragandview.diyview.DiyTextView;
import com.example.dragandview.diyview.DiyviewShapeActivity;
import com.example.dragandview.diyview.ProgressbarActivity;
import com.example.dragandview.diyview.RatingBarViewActivity;
import com.example.dragandview.diyview.TextviewActivity;
import com.example.dragandview.diyview.ViewPagerActivity;
import com.example.dragandview.diywidget.DiyButtonActivity;
import com.example.dragandview.diywidget.DiyViewActivity;
import com.example.dragandview.dray.DragPicNotSortActivity;
import com.example.dragandview.frag.FragmentActivity;
import com.example.dragandview.http.HttpActivity;
import com.example.dragandview.kugou.KugouActivity;
import com.example.dragandview.navigation.NavigationIndexActivity;
import com.example.dragandview.notice.AlertDialogaActivity;
import com.example.dragandview.recyclerviewplus.RecyclerPlusActivity;
import com.example.dragandview.recyclerviewplus.RecyclerviewActivity;
import com.example.dragandview.rxjavapro.RxjavaActivityy;
import com.example.dragandview.seniorUI.GridViewActivity;
import com.example.dragandview.seniorUI.ImageSwitcherActivity;
import com.example.dragandview.seniorUI.ListviewActivity;
import com.example.dragandview.seniorUI.PieChartActivity;
import com.example.dragandview.seniorUI.ProcessBarActivity;
import com.example.dragandview.seniorUI.QQStepActivity;
import com.example.dragandview.seniorUI.RatingBarActivity;
import com.example.dragandview.seniorUI.ScrollerView;
import com.example.dragandview.seniorUI.SeekBarActivity;
import com.example.dragandview.seniorUI.SpnnerActivity;
import com.example.dragandview.seniorUI.TabActivity;
import com.example.dragandview.volley.VolleyActivity;

import java.util.ArrayList;

public class MainActivity extends Activity implements View.OnClickListener {
    private TextView textviewTitlebar;
    private RecyclerView mainpageRecyclerview;
    MainRecyclerViewAdapter mainRecyclerViewAdapter;
    private Button btn_listview,btn_flow,btn_grid;
    private ArrayList<String> datas ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initDatas();
        mainRecyclerViewAdapter = new MainRecyclerViewAdapter(MainActivity.this, datas);
        mainpageRecyclerview.setAdapter(mainRecyclerViewAdapter);
        //添加分割线
        mainpageRecyclerview.addItemDecoration(new DividerItemDecoration(MainActivity.this,DividerItemDecoration.VERTICAL));
        //设置动画
        mainpageRecyclerview.setItemAnimator(new DefaultItemAnimator());
        mainRecyclerViewAdapter.setOnItemClickListener(new MainRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, String data) {
                System.out.println("======data======"+data);
                if(data.equals("拖拽图片不排序")) startActivity(new Intent(MainActivity.this, DragPicNotSortActivity.class));
                if(data.equals("进度条")) startActivity(new Intent(MainActivity.this, ProcessBarActivity.class));
                if(data.equals("拖动条")) startActivity(new Intent(MainActivity.this, SeekBarActivity.class));
                if(data.equals("星级评分条")) startActivity(new Intent(MainActivity.this, RatingBarActivity.class));
                if(data.equals("图像切换")) startActivity(new Intent(MainActivity.this, ImageSwitcherActivity.class));
                if(data.equals("网格视图")) startActivity(new Intent(MainActivity.this, GridViewActivity.class));
                if(data.equals("下拉列表框")) startActivity(new Intent(MainActivity.this, SpnnerActivity.class));
                if(data.equals("饼状图")) startActivity(new Intent(MainActivity.this, PieChartActivity.class));
                if(data.equals("列表视图")) startActivity(new Intent(MainActivity.this, ListviewActivity.class));
                if(data.equals("滚动视图")) startActivity(new Intent(MainActivity.this, ScrollerView.class));
                if(data.equals("选项卡")) startActivity(new Intent(MainActivity.this, TabActivity.class));
                if(data.equals("绘制长方形")) startActivity(new Intent(MainActivity.this, DiyviewShapeActivity.class));
                if(data.equals("自定义按钮")) startActivity(new Intent(MainActivity.this, DiyButtonActivity.class));
                if(data.equals("自定义布局")) startActivity(new Intent(MainActivity.this, DiyViewActivity.class));
                if(data.equals("网络请求")) startActivity(new Intent(MainActivity.this, HttpActivity.class));
                if(data.equals("导航栏")) startActivity(new Intent(MainActivity.this, NavigationIndexActivity.class));
                if(data.equals("对话框")) startActivity(new Intent(MainActivity.this, AlertDialogaActivity.class));
                if(data.equals("Fragment")) startActivity(new Intent(MainActivity.this, FragmentActivity.class));
                if(data.equals("动画")) startActivity(new Intent(MainActivity.this, AnimationActivity.class));
                if(data.equals("volley")) startActivity(new Intent(MainActivity.this, VolleyActivity.class));
                if(data.equals("QQ计步器")) startActivity(new Intent(MainActivity.this, QQStepActivity.class));
                if(data.equals("自定义Textview")) startActivity(new Intent(MainActivity.this, TextviewActivity.class));
                if(data.equals("viewpager顶部")) startActivity(new Intent(MainActivity.this, ViewPagerActivity.class));
                if(data.equals("自定义progressbar")) startActivity(new Intent(MainActivity.this, ProgressbarActivity.class));
                if(data.equals("自定义Ratingbar")) startActivity(new Intent(MainActivity.this, RatingBarViewActivity.class));
                if(data.equals("字母索引列表")) startActivity(new Intent(MainActivity.this, ABCindexViewActivity.class));
                if(data.equals("酷狗效果侧边栏")) startActivity(new Intent(MainActivity.this, KugouActivity.class));
                if(data.equals("垂直滑动")) startActivity(new Intent(MainActivity.this, VerticalSlideActivity.class));
                if(data.equals("九宫格解锁")) startActivity(new Intent(MainActivity.this, LockNinePointActivity.class));
                if(data.equals("RecyclerPlus")) startActivity(new Intent(MainActivity.this, RecyclerPlusActivity.class));
                if(data.equals("RecyclerPro")) startActivity(new Intent(MainActivity.this, RecyclerviewActivity.class));
                if(data.equals("rxjava")) startActivity(new Intent(MainActivity.this, RxjavaActivityy.class));
            }
        });
        mainpageRecyclerview.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_main_flow:
                mainpageRecyclerview.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
                break;
            case R.id.btn_main_listview:
                mainpageRecyclerview.setLayoutManager(new LinearLayoutManager(MainActivity.this,LinearLayoutManager.VERTICAL,false));
                break;
            case R.id.btn_main_grid:
                mainpageRecyclerview.setLayoutManager(new GridLayoutManager(MainActivity.this,2,GridLayoutManager.VERTICAL,false));
                break;
        }
    }
    private void initView(){
        textviewTitlebar = findViewById(R.id.textview_titlebar);
        mainpageRecyclerview = findViewById(R.id.mainpage_recyclerview);
        textviewTitlebar.setText("拖拽和recyclerView的简单使用");
        btn_listview = findViewById(R.id.btn_main_listview);
        btn_flow = findViewById(R.id.btn_main_flow);
        btn_grid = findViewById(R.id.btn_main_grid);
        btn_listview.setOnClickListener(this);
        btn_flow.setOnClickListener(this);
        btn_grid.setOnClickListener(this);
    }
    private void initDatas(){
        datas = new ArrayList<>();
        datas.add("简单的recyclerView的使用");
        datas.add("拖拽图片不排序");
        datas.add("进度条");
        datas.add("拖动条");
        datas.add("星级评分条");
        datas.add("图像切换");
        datas.add("网格视图");
        datas.add("下拉列表框");
        datas.add("饼状图");
        datas.add("列表视图");
        datas.add("滚动视图");
        datas.add("选项卡");
        datas.add("绘制长方形");
        datas.add("自定义按钮");
        datas.add("自定义布局");
        datas.add("网络请求");
        datas.add("对话框");
        datas.add("导航栏");
        datas.add("Fragment");
        datas.add("动画");
        datas.add("volley");
        datas.add("图片轮播");
        datas.add("QQ计步器");
        datas.add("自定义Textview");
        datas.add("viewpager顶部");
        datas.add("自定义progressbar");
        datas.add("自定义Ratingbar");
        datas.add("字母索引列表r");
        datas.add("酷狗效果侧边栏");
        datas.add("垂直滑动");
        datas.add("九宫格解锁");
        datas.add("RecyclerPlus");
        datas.add("RecyclerPro");
        datas.add("rxjava");

    }
}
